<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    const foo = () => {
        var arr = []
        var i

        for (i = 0;i < 10;i++) {
            arr[i] = function (){
                console.log(i) //函数内部没有i，去外面找，外面用var声明了一个变量i，循环i是在等于10停下，i值为10
            }
        }

        return arr[0]
    }
    console.log(foo())
    foo()()
</script>
</body>
</html>